from app.extensions import db
from datetime import date

class User(db.Model):
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    email = db.Column(db.String(32),unique=True,nullable=False)
    nikename = db.Column(db.String(20),unique=True,nullable=False)
    password = db.Column(db.String(100),nullable=False)


class Book(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(20), nullable=False)
    year = db.Column(db.Date)
    page = db.Column(db.Integer)
    money = db.Column(db.Integer)
    ISBN = db.Column(db.Integer,unique=True,nullable=False)
    description = db.Column(db.Text)



class OwnBook(db.Model):
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    uid = db.Column(db.Integer,nullable=False)
    bid = db.Column(db.Integer,nullable=False)


class HopeBook(db.Model):
    id = db.Column ( db.Integer, primary_key=True, autoincrement=True )
    uid = db.Column(db.Integer,nullable=False)
    bid = db.Column(db.Integer,nullable=False)


class ShareRecord(db.Model):
    id = db.Column ( db.Integer, primary_key=True, autoincrement=True )
    send = db.Column(db.String(20),nullable=False)
    receive = db.Column(db.String(20),nullable=False)
    bookname = db.Column(db.String(20),nullable=False)
